package com.xyy.saas.payment.merchant.core.dto;

import com.xyy.saas.payment.common.exception.PaymentException;
import com.xyy.saas.payment.cores.enums.BusinessIdTypeEnum;
import com.xyy.saas.payment.cores.enums.InvokerEnum;
import com.xyy.saas.payment.cores.enums.ResultCodeEnum;
import lombok.Builder;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

@Data
public class PaymentAuthParam2 {
    // 业务线
    private BusinessIdTypeEnum businessIdType;
    // 业务侧商户标识
    private String businessId;
    // 鉴权类型
    private InvokerEnum invoker;
    // 认证金额
    private String amount;
    // 认证单号
    private String orderNo;
    // 扩展字段
    private String extra;

    /**
     * 检验参数
     */
    public void checkParam() throws PaymentException {
        if(businessIdType == null) {
            throw new PaymentException(ResultCodeEnum.PARAM_ERROR.getCode(), "业务线（businessIdType）不能为空");
        }

        if(StringUtils.isBlank(businessId)) {
            throw new PaymentException(ResultCodeEnum.PARAM_ERROR.getCode(), "商户标识（businessId）不能为空");
        }

        if(StringUtils.isBlank(amount)) {
            throw new PaymentException(ResultCodeEnum.PARAM_ERROR.getCode(), "金额（amount）不能为空");
        }

        if(StringUtils.isBlank(orderNo)) {
            throw new PaymentException(ResultCodeEnum.PARAM_ERROR.getCode(), "鉴权短信码（orderNo）不能为空");
        }
    }
}
